<div class="modal-dialog" style="width: 1000px;">
<form class="form-horizontal form-validate form-modal" method="post" action="{:url('info')}">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">&times;</button>
            <h4 class="modal-title">{$row['id'] > 0?'编辑门店':'添加门店'}</h4>
        </div>
        <div class="modal-body" style="height: 700px;max-height: 600px;">
            <div class="form-group">
                <label class="control-label">门店名称：</label>
                <div class="col-sm-7 must">
                    <input type="text" class="input-max" data-rule-maxlength="20" data-rule-required="true" name="store_name" value="{$row.store_name}" >
                </div>
            </div>
            <div class="form-group">
                <label class="control-label">门店电话：</label>
                <div class="col-sm-7 ">
                    <input type="text" class="input-max" data-rule-maxlength="20" data-rule-required="true" name="store_tel" value="{$row.store_tel}" >
                </div>
            </div>
            <div class="form-group">
                <label class="control-label">门店区域：</label>
                <div class="col-sm-7 must">
                    <select name="province" id="province" style="width:120px;"  class="region_sel" nextsel="city|district" sel_val="100000|{$row['province']}">
                        <option value="">请选择</option>
                    </select>
                    <select name="city" id="city" style="width:120px;"  class="region_sel" nextsel="district" sel_val="{$row['province']}|{$row['city']}">
                        <option value="">请选择</option>
                    </select>
                    <select name="district" id="district" style="width:120px;"  class="region_sel" nextsel="street" sel_val="{$row['city']}|{$row['district']}">
                        <option value="">请选择</option>
                    </select>
                    <select name="street" id="street" style="width:120px;" class="region_sel" sel_val="{$row['district']}|{$row['street']}">
                        <option value="">请选择</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label">门店地址：</label>
                <div class="col-sm-7">
                    <a href="javascript:;" style="margin-bottom: 5px;"
                       data-target="#mymodal-data"
                       data-toggle="modal" class="btn btn-sm btn-default" onclick="aaa()"><i class="fa fa-location-arrow m-r-xs"></i>获取地址和经纬度</a>
                  <textarea id="store_address" name="store_address" class="input-max">{$row.store_address}</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label">经纬度：</label>
                <div class="col-sm-7 ">
                    <input type="text" class="input-max" data-rule-maxlength="80" data-rule-required="true" name="lnglat" value="{$row.lnglat}" >
                </div>
            </div>
            <div class="form-group">
                <label class="control-label">门店图片：</label>
                <div class="col-sm-7">
                    <div class="defUpImgBox" data-toggle="uploaderOne">
                        <img id="img_logo" src="{$row.store_image|default='__STATIC__/main/img/image.png'}">
                        <input id="input_logo" type="hidden"  name="store_image"  value="{$row.store_image}">
                        <div class="tips">点击上传</div>
                    </div>
                    <p>
<!--                        <span class="help-inline">图片尺寸：750*420像素</span>-->
<!--                        <a href="javascript:;" onclick="$('#input_logo').val('');$('#img_logo').attr('src','__STATIC__/main/img/image.png');"><i class="fa fa-trash-o m-r-xs"></i>清除图片</a>-->
                    </p>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label">是否显示：</label>
                <div class="col-sm-2controls">
                    <label class="radio-inline">
                        <input name="status" value="1" {$row['status']==1?'checked':''} class="js_undertake " type="radio" >
                        是
                    </label>
                    <label class="radio-inline">
                        <input name="status" value="0" {$row['status']==0?'checked':''} class="js_undertake" type="radio" >否
                    </label>
                </div>
                <div class="clearfix"></div>
            </div>
        </div>
        <div class="modal-footer">
            <input  type="hidden" name="id" value="{$row.id|intval}"/>
            <button type="submit" class="btn btn-primary" data-loading-text="保存中..." disabled>保存</button>
            <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
        </div>
    </div>
    </form>
    <div class="modal fade" id="mymodal-data" tabindex="-1" role="dialog"
         aria-labelledby="mySmallModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false">
        <div class="modal-dialog" style="width: 800px;">
            <iframe
                    id="inlineFrameExample"
                    title="选择地址"
                    width="800"
                    height="600"
                    frameborder=0
                    style="border: 1px solid #e1e1e1;box-shadow: 4px 5px 5px #F1F1F1;"
                    src="https://apis.map.qq.com/tools/locpicker?type=1&key=53YBZ-RHPWF-4CHJU-NPEQT-PPVXZ-SAFKA&referer=myapp">
            </iframe>
        </div>
    </div>
</div>
<script>
    window.addEventListener(
        'message',
        function (event) {
            // 接收位置信息，用户选择确认位置点后选点组件会触发该事件，回传用户的位置信息
            var loc = event.data;
            if (loc && loc.module === 'locationPicker') {
                // 防止其他应用也会向该页面post信息，需判断module是否为'locationPicker'
                window.parent.selectAdderss(loc);

            }
        },
        false,
    );
    function aaa(){
        $("#mymodal-data").show();
        $('.modal-backdrop:last').show();
    }

    function selectAdderss(loc){
        $("#mymodal-data").hide();
        $('.modal-backdrop:last').hide();
        $('input[name="lnglat"]').val(loc.latlng.lng+','+loc.latlng.lat);
        $('#store_address').val(loc.poiaddress);
    }
</script>
